/*!
\file Edge.h
\brief Contains declaration of Edge.
\ingroup Graph
*/

#ifndef EDGE_H
#define EDGE_H

#include"Node.h"

/*!
\class Edge
\brief Represents an Edge. Constructor may only be called by Graph.
\ingroup Graph
*/

class Edge{
public:
	//Copy constructor
	Edge( const Edge &other );
	//!< Copy constructor. This is the only way in which a user is allowed to create an Edge.
	
	//Query functions
	Node from()const;
	//!< Returns Node in which Edge starts.
	Node to()const;
	//!< Returns Node in which Edge ends.
	QString label()const;
	//!< Returns label of Edge.
	int identifier()const{ return m_identifier; }
	//!< Returns identifier of Edge.
	QString toString()const;
	//!< Returns string representation of Edge.
	
	//Overloaded operator. Only the identifier has to be compared. No two edges with same identifier should be present in a graph.
	bool operator==(const Edge &other)const{ return other.identifier() == m_identifier; }
	//!< Comparison operator.
private:
	friend class Graph;
	Node m_from;
	Node m_to;
	QString m_label;
	int m_identifier;
	
	QString _toDOT( bool isDirected )const;
	
	//Private constructor. Can only be called by Graph.
	Edge( Node from, Node to, QString label, int identifier );
};

#endif
